home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software6 / Product2 / adblock-0.5.2.039-fx.xpi / nsAdblock.js < prev   
Text File  |  2004-05-23  |  2KB  |  66 lines

  1. const _ADBLOCK_CONTRACTID = "@mozilla.org/adblock;1";
  2. const _ADBLOCK_CID = Components.ID('{34274bf4-1d97-a289-e984-17e546307e4f}');
  3.  
  4. const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
  5. const JSLOADER_CONTRACTID = "@mozilla.org/moz/jssubscript-loader;1";
  6.  
  7. /*
  8.  * Module object
  9.  */
  10.  
  11. var module =
  12. {
  13.     factoryLoaded: false,
  14.  
  15.     registerSelf: function(compMgr, fileSpec, location, type)
  16.     {
  17.         compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  18.         compMgr.registerFactoryLocation(_ADBLOCK_CID, 
  19.                                         "Adblock content policy",
  20.                                         _ADBLOCK_CONTRACTID,
  21.                                         fileSpec, location, type);
  22.  
  23.         var catman = Components.classes[CATMAN_CONTRACTID].getService(Components.interfaces.nsICategoryManager);
  24.         catman.addCategoryEntry("content-policy", _ADBLOCK_CONTRACTID,
  25.                             _ADBLOCK_CONTRACTID, true, true);
  26.     },
  27.  
  28.     unregisterSelf: function(compMgr, fileSpec, location)
  29.     {
  30.         compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  31.  
  32.         compMgr.unregisterFactoryLocation(_ADBLOCK_CID, fileSpec);
  33.         var catman = Components.classes[CATMAN_CONTRACTID].getService(Components.interfaces.nsICategoryManager);
  34.         catman.deleteCategoryEntry("content-policy", _ADBLOCK_CONTRACTID, true);
  35.     },
  36.  
  37.     getClassObject: function(compMgr, cid, iid)
  38.     {
  39.         if (!cid.equals(_ADBLOCK_CID))
  40.             throw Components.results.NS_ERROR_NO_INTERFACE;
  41.  
  42.         if (!iid.equals(Components.interfaces.nsIFactory))
  43.             throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  44.  
  45.         if (!this.factoryLoaded || !patterns)
  46.         {
  47.             var loader = Components.classes[JSLOADER_CONTRACTID].getService(Components.interfaces.mozIJSSubScriptLoader);
  48.             loader.loadSubScript('chrome://adblock/content/component.js');
  49.             this.factoryLoaded = factory;
  50.         }
  51.  
  52.         return factory;
  53.     },
  54.  
  55.     canUnload: function(compMgr)
  56.     {
  57.         return true;
  58.     }
  59. };
  60.  
  61. // module initialisation
  62. function NSGetModule(comMgr, fileSpec)
  63. {
  64.     return module;
  65. }
  66.